Skip to content

bpo-45490: Convert unicodeobject.h macros to static inline functions#31221

Closed
vstinner wants to merge 1 commit intopython:mainfrom
vstinner:unicode_static_inline
Closed

bpo-45490: Convert unicodeobject.h macros to static inline functions#31221
vstinner wants to merge 1 commit intopython:mainfrom
vstinner:unicode_static_inline

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Feb 8, 2022

  • Convert unicodeobject.h macros to static inline functions.

  • Reorder functions to declare functions before their first usage.

  • Add "kind" variable to PyUnicode_READ_CHAR() and
    PyUnicode_MAX_CHAR_VALUE() functions to only call PyUnicode_KIND()
    once.

  • PyUnicode_KIND() now returns an "enum PyUnicode_Kind".

  • Simplify PyUnicode_GET_SIZE().

  • Add assertions to PyUnicode_WRITE() on the max value.

  • Add cast macros:

    • _PyASCIIObject_CAST()
    • _PyCompactUnicodeObject_CAST()
    • _PyUnicodeObject_CAST()
  • The following functions are now declared as deprecated using
    Py_DEPRECATED(3.3):

    • PyUnicode_GET_SIZE()
    • PyUnicode_GET_DATA_SIZE()
    • PyUnicode_AS_UNICODE()
    • PyUnicode_AS_DATA()
    • The implementation of these functions disable deprecation
      warnings in their body.
  • PyUnicode_READ_CHAR() now uses PyUnicode_1BYTE_DATA(),
    PyUnicode_2BYTE_DATA() and PyUnicode_4BYTE_DATA().

  • Replace "const PyObject*" with "PyObject*" in _decimal.c
    and pystrhex.c: PyUnicode_READY() can modify the object.

  • Replace "const void *data" with "void *data" in some unicodedata.c
    and unicodeobject.c functions which use PyUnicode_WRITE(): data is
    used to modify the string.

https://bugs.python.org/issue45490

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants